home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / COMPNENT / SAWIN95 / HKTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1996-10-28  |  2KB  |  80 lines

  1. unit hktest;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   SysHot, StdCtrls, Menus, WComp;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     SysHotKey1: TSysHotKey;
  12.     Label1: TLabel;
  13.     Label2: TLabel;
  14.     Label3: TLabel;
  15.     CheckBox1: TCheckBox;
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure SysHotKey1HotKey(Sender: TObject; Index: Integer);
  18.     procedure CheckBox1Click(Sender: TObject);
  19.   private
  20.     FActive : Boolean;
  21.     FShowing: Boolean;
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.DFM}
  33.  
  34. procedure TForm1.FormCreate(Sender: TObject);
  35. begin
  36.   SysHotKey1.AddHotKey(vkSpace, [hkAlt]);
  37.   SysHotKey1.AddHotKey(vkF4, [hkAlt]);
  38.   SysHotKey1.AddHotKey(vkSnapshot, []);
  39.   SysHotKey1.AddHotKey(vkSpace, []);
  40.   SysHotKey1.AddHotKey(vkReturn, []);
  41.   FActive := False;
  42.   FShowing := False;
  43. end;
  44.  
  45. procedure TForm1.SysHotKey1HotKey(Sender: TObject; Index: Integer);
  46. begin
  47.   if not FActive and not FShowing then SetForeGroundWindow(Handle);
  48.   case Index of
  49.     0, 1 : begin
  50.              FActive := True;
  51.              ShowMessage('Sorry, this key has been overruled!!!!');
  52.              FActive := False;
  53.            end;
  54.     2    : begin
  55.              FActive := True;
  56.              ShowMessage('Didn''t you mother teach you that it isn''t nice to steal other people''s graphics?');
  57.              FActive := False;
  58.            end;
  59.     3, 4 : if not FShowing then
  60.             begin
  61.               FShowing := True;
  62.               ShowMessage('You''ll have to use the mouse instead of the keyboard to do this....!!'+#13+#10+'(The ENTER and SPACE keys are trapped as well....)');
  63.               FShowing := False;
  64.             end;
  65.   end;
  66. end;
  67.  
  68. procedure TForm1.CheckBox1Click(Sender: TObject);
  69. begin
  70.   SysHotKey1.Active := TCheckBox(Sender).Checked;
  71.   FActive := True;
  72.   if SysHotKey1.Active then
  73.    ShowMessage('The hotkeys are now active')
  74.   else
  75.    ShowMessage('The hotkeys have been deactivated.');
  76.   FActive := False;
  77. end;
  78.  
  79. end.
  80.